package com.wewins.fota.mapper;

import com.wewins.fota.bean.po.UserInfo;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface UserInfoMapper {
    @Select("SELECT * FROM user_info where username = #{username}")
    @Results(id = "UserInfoQueryMap", value = {
            @Result(id = true, property = "id", column = "id"),
            @Result(property = "userRole", column = "role")
    })
    UserInfo findByUsername(String username);

    int deleteById(int id);

    @Select("SELECT * FROM user_info")
    @ResultMap("UserInfoQueryMap")
    List<UserInfo> queryAll();

    @Select("SELECT * FROM user_info WHERE id = #{id}")
    @ResultMap("UserInfoQueryMap")
    UserInfo findById(int id);
}
